package com.yzq.enums;
import lombok.Getter;

/**
 * 异常枚举类，与HTTP状态码保持一致，定义项目通用错误码
 */
@Getter
public enum ErrorCode {
    // 成功
    SUCCESS(200, "操作成功"),

    // 客户端错误 4xx
    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未授权访问"),
    FORBIDDEN_USER_NOT_LOGIN(402, "用户未登录"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),
    CONFLICT(409, "资源冲突"),

    // 服务端错误 5xx
    INTERNAL_SERVER_ERROR(500, "服务器内部错误"),
    SERVICE_UNAVAILABLE(503, "服务不可用"),
    OPERATION_ERROR(510, "操作失败"),

    // 自定义业务错误 10xx
    USER_NOT_FOUND(1001, "用户不存在"),
    IMAGE_UPLOAD_FAILED(1002, "图片上传失败"),
    COLLABORATION_PERMISSION_DENIED(1003, "协作权限不足");

    private final int code;
    private final String message;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
}